﻿<%@ Page Title="Data Dictionary" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="DataDictionary.aspx.cs" Inherits="NetDon.OA.Portal.Admin.DataDictionary" %>

<%@ Register Src="../Controls/GridPager.ascx" TagName="GridPager" TagPrefix="uc1" %>
<%@ Register Assembly="NineRays.WebControls.FlyTreeView" Namespace="NineRays.WebControls"
    TagPrefix="NineRays" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script language="javascript" type="text/javascript">
        function btnDeleteEntryClick(value) {
            
             $confirm('您确定要删除此项吗?', function(result) {
                if (result) {
                    $text($get('<%=fieldValue.ClientID %>'), value);
                    $get('<%=btnDeleteEntry.ClientID %>').click();
                }
            })
        }
        function btnModifyEntryClick(type, entryValue, entryName) {
             
           $prompt('请输入名称', entryName, function(sender, value) {
                if(String.isNullOrEmpty(value.trim())){
                    $alert('名称不可为空.');
                    return;
                }
                PageMethods.ModifyDictionaryData(type, entryValue, value, saveEntryCallback, null, { prompter: sender, value: value });
            });
        }
        function btnAddEntryClick(type) {
            
            $prompt('请输入名称', '', function(sender, value) {
                if(String.isNullOrEmpty(value.trim())){
                    $alert('名称不可为空.');
                    return;
                }
                PageMethods.AddDictionaryData(type, value, saveEntryCallback, null, { prompter: sender, value: value });
            });
        }
        function saveEntryCallback(result, context) {
            if (result) {
                context.prompter.hide();
                $get('<%=btnRefreshEntries.ClientID %>').click();
            } else {
             $alert(String.format("名称 '{0}' 已存在.", context.value));
              }
        }

        function treeTypesSelectedNodeChanged() {
            $get('<%=btnRefreshEntries.ClientID %>').click();
        }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div style="float: left;">
                <NineRays:FlyTreeView ID="treeTypes" runat="server" Width="200px" DrawLines="false"
                    OnSelectedNodeChangedJavascript="treeTypesSelectedNodeChanged">
                </NineRays:FlyTreeView>
            </div>
            <div style="float: left; margin-left: 10px;">
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            <div style="width: 430px; overflow: hidden;">
                                <NetDon:GridView ID="gridItem" runat="server" OnRowDataBound="gridItem_RowDataBound"
                                    AutoGenerateColumns="false" OnRowCommand="gridItem_RowCommand" PageSize="1000">
                                    <Columns>
                                        <NetDon:BoundField HeaderText="标题" DataField="Name" HtmlEncode="true">
                                        </NetDon:BoundField>
                                        <NetDon:TemplateField HeaderText="操作" ItemStyle-Width="120px" HeaderStyle-Width="80px">
                                            <ItemTemplate>
                                                <asp:ImageButton ID="btnDelete" runat="server" SkinID="Delete" CommandName="Delete"
                                                    CausesValidation="false" />
                                                <asp:ImageButton ID="btnModify" SkinID="Modify" runat="server" CommandName="Modify"
                                                    CausesValidation="false" />
                                                <asp:ImageButton ID="btnMoveUp" SkinID="MoveUp" runat="server" CommandName="MoveUp"
                                                    CausesValidation="false" />
                                                <asp:ImageButton ID="btnMoveDown" SkinID="MoveDown" runat="server" CommandName="MoveDown"
                                                    CausesValidation="false" />
                                            </ItemTemplate>
                                            <HeaderStyle Width="80px" />
                                            <ItemStyle Width="120px" />
                                        </NetDon:TemplateField>
                                    </Columns>
                                </NetDon:GridView>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div style="margin-top: 10px; ">
                                <asp:Button ID="btnAddItem" runat="server" Enabled="False" 
                                    Text="创建"></asp:Button>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
            <asp:HiddenField ID="fieldValue" runat="server" />
            <asp:Button ID="btnDeleteEntry" runat="server" OnClick="btnDeleteEntry_Click" Style="display: none"
                CausesValidation="false" />
            <asp:Button ID="btnRefreshEntries" runat="server" OnClick="btnRefreshEntries_Click"
                Style="display: none" CausesValidation="false" />
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
